#define  _CRT_SECURE_NO_WARNINGS 1
struct listNode {
	int val;
	struct listNode* next;
};
typedef struct listNode listNode;
struct listNode* getintersectionNode(struct listNode* headA, struct listNode* headB) 
{
	listNode* pa = headA;
	listNode* pb = headB;
	int sizeA = 0; int sizeB = 0;
	while (headA)
	{
		++sizeA;
		pa = pa->next;
	}
	while (headB)
	{
		++sizeB;
		pb = pb->next;
	}
	listNode* longlist = headA;
	listNode* shortlist = headB;
	if (sizeA < sizeB)
	{
		 longlist=headB;
		 shortlist = headA;

	}
	int gap = abs(sizeA - sizeB);
		while (gap--) {
			longlist = longlist->next;
		}
	while (shortlist) {
		if (shortlist == longlist)
		{
			return shortlist;

		}
		shortlist = shortlist->next;
		longlist = longlist->next;
	}
	return NULL;


}